package fr.utbm.aiechat;

import android.app.Activity;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Settings
{
	private static Settings instance = null;
	private SharedPreferences SharedPreferences;
	private SharedPreferences.Editor Editor;
	
	protected Settings(Activity MyActivity)
	{
		SharedPreferences = PreferenceManager.getDefaultSharedPreferences(MyActivity);
		Editor = SharedPreferences.edit();
	}
	
	// Singleton Pattern
	public static Settings getInstance()
	{
		return instance ;
	}
	
	// Singleton Pattern
	public static Settings createInstance(Activity MyActivity)
	{
		if(instance == null)
		{
			instance = new Settings(MyActivity);
		}
		return instance;
	}
	
	public boolean hasNickname()
	{
		return !getNickname().equals("");
	}
	
	public String getNickname()
	{
		return SharedPreferences.getString("pseudopref", "");
	}	
	
	public void setNickname(String Nick)
	{
		Editor.putString("pseudopref", Nick);
		Editor.commit();
	}
	
	public String getSexe()
	{
		return SharedPreferences.getString("sexepref", "default");
	}
	
	public void setSexe(String sexe)
	{
		Editor.putString("sexepref", sexe);
		Editor.commit();
	}
	
	/*public boolean getPermissionGPS(){
		return SharedPreferences.getBoolean("permissionGPSpref", true);
	}*/

	public boolean hasSexe() {
		return !(getSexe().equals("") || getSexe().equals("default"));
	}

}
